using System;

namespace Dida
{
	public class Hasher
	{
		UInt32 hash = 0;

		public void Add(UInt32 val)
		{
			unchecked
			{
				hash *= (UInt32)0x01000193;
				hash ^= val & 0xff;
				hash *= (UInt32)0x01000193;
				hash ^= (val >> 8) & 0xff;
				hash *= (UInt32)0x01000193;
				hash ^= (val >> 16) & 0xff;
				hash *= (UInt32)0x01000193;
				hash ^= (val >> 24);
			}
		}

		public void Add<T>(T val)
		{
			Add((int)val.GetHashCode());
		}

		public int Value
		{
			get
			{
				unchecked
				{
					return (int)hash;
				}
			}
		}
	}
}